home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
THINKC
/
4_0
/
3DMAZE
/
3_D_MAZE.C
next >
Wrap
Text File
|
1991-02-28
|
3KB
|
145 lines
/* ===================================
File: P_D_Maze.c
Function: Handle all operations for this window
History: 2/15/91 Original by Prototyper.
================================= */
#include "P_D_Maze.h"
/* *********************************** */
/* These are the other includes for general routines */
#include "Strings.h"
extern char * strcpy(Str255 *, char *);
/* *********************************** */
#define TRUE 1
#define FALSE 0
#define NIL 0
/* *********************************** */
WindowPtr MyWindow;
static Rect tempRect,temp2Rect;
static short Index;
static ControlHandle CtrlHandle;
static Str255 sTemp;
static OSErr MyErr;
/* ====================================== */
/* Initialize us so all our routines can be activated */
void Init_P_D_Maze()
{
MyWindow = NIL;
}
/* ================================= */
/* Close our window */
void Close_P_D_Maze(whichWindow,theInput)
WindowPtr whichWindow;
TEHandle *theInput;
{
if ((MyWindow != NIL) && ((MyWindow == whichWindow) || (whichWindow == (WindowPtr)-1)))
{
DisposeWindow(MyWindow);
MyWindow = NIL;
}
}
/* ================================= */
/* ====================================== */
/* Update our window, someone uncovered a part of us */
void UpDate_P_D_Maze(whichWindow)
WindowPtr whichWindow;
{
WindowPtr SavePort;
if ((MyWindow != NIL) && (MyWindow == whichWindow))
{
GetPort(&SavePort);
SetPort(MyWindow);
DrawControls(MyWindow);
DrawMaze();
SetPort(SavePort);
}
}
/* ================================= */
/* Open our window and draw everything */
void Open_P_D_Maze(theInput)
TEHandle *theInput;
{
short Index;
Rect dataBounds;
Point cSize;
if (MyWindow == NIL)
{
MyWindow = GetNewWindow(1,NIL, (WindowPtr)-1);
SetPort(MyWindow);
ShowWindow(MyWindow);
SelectWindow(MyWindow);
InitMaze();
DrawMaze();
}
else
SelectWindow(MyWindow);
DrawMaze();
}
/* ================================= */
/* Handle action to our window, like controls */
void Do_P_D_Maze(myEvent, theInput)
EventRecord *myEvent;
TEHandle *theInput;
{
short RefCon;
short code;
short theValue;
WindowPtr whichWindow;
Point myPt;
ControlHandle theControl;
/* Start of Window handler */
if (MyWindow != NIL)
{
code = FindWindow(myEvent->where, &whichWindow);
if ((myEvent->what == mouseDown) && (MyWindow == whichWindow))
{
myPt = myEvent->where;
GlobalToLocal(&myPt);
}
if ((MyWindow == whichWindow) && (code == inContent))
{
code = FindControl(myPt, whichWindow, &theControl);
if (code != 0)
code = TrackControl(theControl,myPt, NIL);
}
}
}
/* ================================= */